import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { UiserviceProvider } from '../../providers/uiservice/uiservice';
import { BusiserviceProvider } from '../../providers/busiservice/busiservice';

/**
 * Generated class for the MyzhiwPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-myzhiw',
  templateUrl: 'myzhiw.html',
})
export class MyzhiwPage {
  userid: any;
  selfZwlist = [];
  constructor(public navCtrl: NavController, public navParams: NavParams, public busi: BusiserviceProvider, private uiservice: UiserviceProvider) {
    this.userid = localStorage.getItem("userid");
    
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad MyzhiwPage');
    
  }
  ionViewDidEnter(){
    this.querySelfZwList();
  }
  querySelfZwList() {
    this.uiservice.showLoading();
    this.busi.querySelfZwList(this.userid).subscribe(
      data => {
        this.uiservice.hideLoading();
        if (data._success) {
          this.selfZwlist = data.result;
        } else {
          this.uiservice.showAlert(data._message);
        }
      },
      error => {
        this.uiservice.hideLoading();
      }
    )
  }
  zwdetail(zw) {
    this.navCtrl.push("ZwdetailPage", { zw: zw });
  }
  addzw() {
    this.navCtrl.push("ZwaddPage");
  }

}
